package createThread.cn.tedu.threaddemo.test6;


import java.util.Scanner;

public class Test1 {
    private static int flag = 0;
    private static int num = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while(flag == 0){
                try {
                    Thread.sleep(0);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程1结束");
        });
        Thread t2 = new Thread(()->{
            System.out.println("请输入非0的数字来打破T1线程的执行");
            Scanner scan = new Scanner(System.in);
            flag = scan.nextInt();
            System.out.println("线程2结束");
        });
        t1.start();
        t2.start();
        System.out.println(num);
    }
}
